<?php
/**
 * 描述
 * Created by Paco
 * Date: 2018/8/23 Time: 10:11
 */

namespace App\Http\Controllers\Admin\Auth;


use App\Http\Controllers\Controller;
use App\Http\Request\Auth\AdminStore;
use App\Http\Request\Auth\InfoStore;
use App\Repositories\Auth\AdminRepository;
use Illuminate\Http\Request;

class AdminController extends Controller
{
    private $admin;

    public function __construct(AdminRepository $admin)
    {
        $this->admin = $admin;
    }

    /**
     *
     * 管理员列表
     * @author Paco
     * @createTime 2018/8/23 10:36
     * @param Request $request
     * @return mixed
     */
    public function index(Request $request)
    {
        $params = $request->all();
        return $this->admin->index($params);
    }

    /**
     *
     * 管理员详细信息
     * @author Paco
     * @createTime 2018/8/23 10:58
     * @param $admin_id
     * @return mixed
     */
    public function show($admin_id)
    {
        return $this->admin->show($admin_id);
    }

    /**
     *
     * 更新管理员
     * @author Paco
     * @createTime 2018/8/23 10:41
     * @param AdminStore $admin
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function save(AdminStore $admin, Request $request)
    {
        $params = $admin->validated($request);
        return $this->admin->save($params);
    }


    /**
     *
     * 添加管理员
     * @author Paco
     * @createTime 2018/8/23 11:04
     * @param AdminStore $admin
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(AdminStore $admin, Request $request)
    {
        $params = $admin->validated($request);
        return $this->admin->store($params);
    }

    /**
     *
     * 修改管理员基本信息
     * @author Paco
     * @createTime 2018/8/23 11:21
     * @param InfoStore $info
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function info(InfoStore $info, Request $request)
    {
        $params = $info->validated($request);
        return $this->admin->simpleSave($params);
    }


    public function del(Request $request)
    {
        $ids = $request->input('admin_ids');
        return $this->admin->del($ids);
    }


}